package com.hyz.user.controller;

import com.hyz.common.response.Result;
import com.hyz.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("user")
@RefreshScope
public class UserController {

    @Autowired
    private UserService userService;

    @Value("${server.port}")
    private String port;

    @Value("${text.name}")
    private String name;

    @GetMapping("findUserById/{username}")
    public Result findUserById(@PathVariable("username") String username) {
        System.out.println(port+"====================");
        System.out.println(name+"-----------------");
        return Result.okResult(userService.findUserById(username));
    }

    @GetMapping("findOrderByUserId")
    public Result findOrderByUserId(@RequestParam String username) {
        return Result.okResult(userService.findOrderByUserId(username));
    }
}
